package com.jgjc.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class NumberUtils {

    public static List getMiddleNumbersByTwoNumbers(int startNumber, int endNumber) {
        List numberList = new ArrayList();
        if (startNumber <= 0) {
            startNumber = 0;
            startNumber++;
        }
        for (int i = startNumber; i < endNumber + 1; i++) {
            numberList.add(i);
        }
        return numberList;
    }

    public static List getMiddleNumbersByDHNumbers(String siteRange) {
        List numberList = new ArrayList();
        String[] siteRangeArr = siteRange.split(",");
        for (int i = 0; i < siteRangeArr.length; i++) {
            numberList.add(siteRangeArr[i]);
        }
        return numberList;
    }

    public static List getMiddleNumbersByHGNumbers(String siteRange) {
        List numberList = new ArrayList();
        String[] siteRangeArr = siteRange.split("-");
        int startNumber = Integer.parseInt(siteRangeArr[0]);
        int endNumber = Integer.parseInt(siteRangeArr[1]);
        if (startNumber <= 0) {
            startNumber = 0;
            startNumber++;
        }
        for (int i = startNumber; i < endNumber + 1; i++) {
            numberList.add(i);
        }
        return numberList;
    }

    public static List getSiteNoListUtil(Map<String, Object> requestMap) {
        String siteRange = (String) requestMap.get("siteRange");
        List siteNoList = new ArrayList();
        if (siteRange.contains(",")) {
            siteNoList = getMiddleNumbersByDHNumbers(siteRange);
        } else if (siteRange.contains("-")) {
            siteNoList = getMiddleNumbersByHGNumbers(siteRange);
        } else {
            siteNoList.add(siteRange);
        }
        return siteNoList;
    }
}
